#include "forceOffline.h"
#include "tcp_routines.h"
#include "gheaders.h"


ForceOffLine::ForceOffLine(QString userN)
{
    userName=userN;
}
void ForceOffLine::run()
{
    int notify_fd = tcp_connect(SRV_IP,"1236");
    if(notify_fd < 0)
    {

    }

    char usr_name[USR_LEN];
    strncpy(usr_name,this->userName.toStdString().c_str(),USR_LEN);

    if(writen(notify_fd,usr_name,USR_LEN) < 0)
    {

    }

    int notify;
    if (readn(notify_fd,&notify,sizeof(int)) < 0)
    {

    }

    if(notify == -1)
        emit this->startWatcher();

}
